#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <queue>
#include <complex>
#include <cassert>
 
using namespace std;

const int inf = int(1e9);

struct point {
	int x, y;
};

class Graph {

public:
	vector <point> p;
	vector <vector <int> > g;
	
	Graph() {}
	Graph(vector <point> points, vector <pair <int, int> > e) {
		p = points;
		g.resize((int)p.size());
		for (int i = 0; i < (int)p.size(); i++) {
			g[i].clear();
		}
		for (int i = 0; i < (int)e.size(); i++) {
			g[e[i].first].push_back(e[i].second);
			g[e[i].second].push_back(e[i].first);
		}
	}
	int get_vertices() {
		return (int)g.size();
	}
	pair <int, vector <int> :: iterator> get_iterator(int v) {
		return make_pair(v, g[v].begin());
	}
	bool valid(pair <int, vector <int> :: iterator> it){
		return it.second != g[it.first].end();
	}
	pair <int, vector <int> :: iterator> next(pair <int, vector <int> :: iterator> it){
		return make_pair(it.first, it.second + 1);
	}
	
};

double dist(point a, point b) {
	return sqrt((double)(a.x - b.x) * (a.x - b.x) + (double)(a.y - b.y) * (a.y - b.y));
}

double A(Graph g, int v, int u) {
	vector <double> d;
	d.assign(g.get_vertices(), inf);
	set <pair <double, int> > s;
	vector <double> h;
	h.resize(g.get_vertices());
	for (int i = 0; i < (int)h.size(); i++) {
		h[i] = dist(g.p[i], g.p[u]);
	}
	d[v] = 0;
	s.insert(make_pair(d[v] + h[v], v));
	while (!s.empty()) {
		pair <double, int> cur = *(s.begin());
		s.erase(s.begin());
		if (cur.second == u) {
			return d[u];
		}
		pair <int, vector <int> :: iterator> e = g.get_iterator(cur.second);
		while (g.valid(e)) {
			if (d[cur.second] + dist(g.p[cur.second], g.p[*(e.second)]) < d[*(e.second)]) {
				s.erase(make_pair(d[*(e.second)] + h[*(e.second)], *(e.second)));
				d[*(e.second)] = d[cur.second] + dist(g.p[cur.second], g.p[*(e.second)]);
				s.insert(make_pair(d[*(e.second)] + h[*(e.second)], *(e.second)));
			}
			e = g.next(e);
		}
	}
	return -1;
}

int main() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int n, m;
	scanf("%d %d", &n, &m);
	vector <point> points;
	for (int i = 0; i < n; i++) {
		point cur;
		scanf("%d %d", &cur.x, &cur.y);
		points.push_back(cur);
	}
	vector <pair <int, int> > edges;
	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--;
		b--;
		edges.push_back(make_pair(a, b));
	}
	Graph g(points, edges);
	printf("%.18lf\n", A(g, 0, n - 1));
	return 0;
}
